
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>已有Android工程 集成React Native · 《前端学习笔记》</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="XiaoChen">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-ancre-navigation/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../Egret/Egret 白鹭引擎参考资料.html" />
    
    
    <link rel="prev" href="CodePush 热更新配置及使用.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">前言</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Android</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../Android/Android 多包名打包应用.html">
            
                <a href="../Android/Android 多包名打包应用.html">
            
                    
                    Android 多包名打包应用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../Android/Android UI美化之 shape的使用及其属性总结.html">
            
                <a href="../Android/Android UI美化之 shape的使用及其属性总结.html">
            
                    
                    Android UI美化之 shape的使用及其属性总结
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">ReactNative</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="CodePush 热更新配置及使用.html">
            
                <a href="CodePush 热更新配置及使用.html">
            
                    
                    CodePush 热更新配置及使用
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="3.2" data-path="已有Android工程 集成React Native.html">
            
                <a href="已有Android工程 集成React Native.html">
            
                    
                    已有Android工程 集成React Native
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Egret</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../Egret/Egret 白鹭引擎参考资料.html">
            
                <a href="../Egret/Egret 白鹭引擎参考资料.html">
            
                    
                    Egret 白鹭引擎参考资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../Egret/EGER PRO.html">
            
                <a href="../Egret/EGER PRO.html">
            
                    
                    EGER PRO
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../Egret/Egret 寻路.html">
            
                <a href="../Egret/Egret 寻路.html">
            
                    
                    Egret 寻路
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">工具</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../Tools/homebrew 使用.html">
            
                <a href="../Tools/homebrew 使用.html">
            
                    
                    homebrew 使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../Tools/git 使用.html">
            
                <a href="../Tools/git 使用.html">
            
                    
                    git 使用
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">小程序</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../MiniApp/Atom 完美支持 WePY 小程序开发.html">
            
                <a href="../MiniApp/Atom 完美支持 WePY 小程序开发.html">
            
                    
                    Atom 完美支持 WePY 小程序开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../MiniApp/Atom 插件安装慢解决方案.html">
            
                <a href="../MiniApp/Atom 插件安装慢解决方案.html">
            
                    
                    Atom 插件安装慢解决方案
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Vue</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../Vue2/Web 前端环境搭建.html">
            
                <a href="../Vue2/Web 前端环境搭建.html">
            
                    
                    Web 前端环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../Vue2/Vue 项目搭建.html">
            
                <a href="../Vue2/Vue 项目搭建.html">
            
                    
                    Vue 项目搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../Vue2/初识 VueCli 3.html">
            
                <a href="../Vue2/初识 VueCli 3.html">
            
                    
                    初识 VueCli 3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.4" data-path="../Vue2/使用 VueCli 3.html">
            
                <a href="../Vue2/使用 VueCli 3.html">
            
                    
                    使用 VueCli 3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.5" data-path="../Vue2/VueCli 3 项目配置.html">
            
                <a href="../Vue2/VueCli 3 项目配置.html">
            
                    
                    VueCli 3 项目配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.6" data-path="../Vue3/Vue3探索.html">
            
                <a href="../Vue3/Vue3探索.html">
            
                    
                    初识 Vue3
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">微前端</li>
        
        
    
        <li class="chapter " data-level="8.1" data-path="../MicroApp/qiankun/">
            
                <a href="../MicroApp/qiankun/">
            
                    
                    qiankun
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">团队成长</li>
        
        
    
        <li class="chapter " data-level="9.1" data-path="../Team/Web前端开发规范.html">
            
                <a href="../Team/Web前端开发规范.html">
            
                    
                    开发规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="../Team/Web团队建设--npm私库搭建.html">
            
                <a href="../Team/Web团队建设--npm私库搭建.html">
            
                    
                    私库搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.3" data-path="../Team/Web团队建设--自定义脚手架.html">
            
                <a href="../Team/Web团队建设--自定义脚手架.html">
            
                    
                    脚手架搭建
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >已有Android工程 集成React Native</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <p>2017&#x5E74;2&#x6708;27&#x65E5;&#xFF0C;&#x5929;&#x6C14;&#x6674;&#xFF0C;&#x6211;&#x6C38;&#x8FDC;&#x8BB0;&#x5F97;&#x8FD9;&#x5929;&#xFF0C;&#x6211;&#x5FC3;&#x6F6E;&#x6F8E;&#x6E43;&#xFF0C;&#x56E0;&#x4E3A;&#x7EC8;&#x4E8E;&#x628A;<a href="http://utantop.com/" target="_blank">&#x4F18;&#x8C08;TOP</a> &#x96C6;&#x6210;&#x4E86;React Native&#xFF0C;&#x4ECE;&#x53BB;&#x5E74;&#x5F00;&#x59CB;&#xFF0C;&#x516C;&#x53F8;&#x9646;&#x9646;&#x7EED;&#x7EED;&#x7684;&#x96C6;&#x6210;&#x548C;&#x5B66;&#x4E60;React Native&#xFF0C;&#x901A;&#x8FC7;demo&#x7684;&#x5F62;&#x5F0F;&#xFF0C;&#x5199;&#x4E86;&#x4E0D;&#x5C11;&#x7EC4;&#x4EF6;&#x548C;API&#xFF0C;&#x4E5F;&#x80FD;&#x548C;&#x540E;&#x7AEF;&#x8C03;&#x901A;&#xFF0C;&#x4E5F;&#x591A;&#x6B21;&#xFF0C;&#x591A;&#x4E2A;&#x4EBA;&#x5C1D;&#x8BD5;&#x628A;&#x4F18;&#x8C08;TOP&#x96C6;&#x6210;React Native&#xFF0C;&#x4F46;&#x662F;&#x6BCF;&#x6B21;&#x90FD;&#x662F;&#x5931;&#x8D25;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x7F3A;&#x5C11;&#x7ECF;&#x9A8C;&#xFF0C;&#x4E0D;&#x80FD;&#x76F4;&#x63A5;&#x901A;&#x8FC7;&#x9519;&#x8BEF;&#x5224;&#x65AD;&#x539F;&#x56E0;&#xFF0C;&#x53EA;&#x80FD;&#x901A;&#x8FC7;Google&#x67E5;&#x627E;&#x5404;&#x79CD;&#x8D44;&#x6599;&#xFF0C;&#x6162;&#x6162;&#x89E3;&#x51B3;&#xFF0C;&#x4E0B;&#x9762;&#x8BB0;&#x5F55;&#x4E86;&#x6211;&#x4EEC;&#xFF0C;<a href="http://utantop.com/" target="_blank">&#x4F18;&#x8C08;TOP</a> &#x539F;&#x751F; &#x96C6;&#x6210;React Native &#x7684;&#x90A3;&#x4E9B;&#x4E8B;&#x3002;&#x4E5F;&#x8BB8;&#x4E5F;&#x662F;&#x4F60;&#x7684;&#x90A3;&#x4E9B;&#x4E8B;&#xFF1F;</p>
<h3 id="&#x5E38;&#x89C4;&#x601D;&#x8DEF;&#xFF1A;"><a name="&#x5E38;&#x89C4;&#x601D;&#x8DEF;&#xFF1A;" class="anchor-navigation-ex-anchor" href="#&#x5E38;&#x89C4;&#x601D;&#x8DEF;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5E38;&#x89C4;&#x601D;&#x8DEF;&#xFF1A;</h3>
<p>&#x901A;&#x8FC7;&#x767E;&#x5EA6;&#x641C;&#x7D22; <code>&#x5DF2;&#x6709;Android&#x5DE5;&#x7A0B;&#x96C6;&#x6210;ReactNative</code> &#x51FA;&#x73B0;&#x4E00;&#x5927;&#x5806;&#x6559;&#x7A0B;&#xFF0C;&#x5927;&#x90E8;&#x5206;&#x6559;&#x7A0B;&#x90FD;&#x662F;&#x901A;&#x8FC7;&#x5728;&#x539F;&#x6765;&#x7684;&#x57FA;&#x7840;&#x4E0A;&#x589E;&#x52A0;React Native&#x7684;&#x652F;&#x6301;&#xFF0C;&#x6BD4;&#x5982;&#x8FD9;&#x4E2A;&#xFF1A;<a href="http://blog.csdn.net/jj120522/article/details/51982228" target="_blank">&#x300A;Android&#x4E4B;&#x539F;&#x751F;&#x9879;&#x76EE;&#x96C6;&#x6210;React Native&#x300B;</a> &#xFF0C;&#x6298;&#x4E5F;&#x662F;&#x5B98;&#x65B9;&#x63A8;&#x8350;&#x7684;&#x96C6;&#x6210;&#x65B9;&#x5F0F;&#xFF0C;&#x6211;&#x4E5F;&#x63A8;&#x8350;&#x8FD9;&#x4E2A;&#xFF0C;&#x53EA;&#x662F;&#x6211;&#x8FD9;&#x6837;&#xFF0C;&#x4E00;&#x76F4;&#x62A5;&#x9519;&#xFF0C;&#x6709;&#x4E00;&#x4E2A;&#x542F;&#x52A8; MainaAtivity&#x7684;&#x9519;&#xFF0C;&#x4E00;&#x76F4;&#x8FC7;&#x4E0D;&#x53BB;&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x5C31;&#x6362;&#x4E00;&#x79CD;&#x601D;&#x8DEF;&#x3002;&#x3002;&#x3002;</p>
<h3 id="&#x5728;react-native&#x57FA;&#x7840;&#x4E0A;&#x589E;&#x52A0;&#x539F;&#x751F;"><a name="&#x5728;react-native&#x57FA;&#x7840;&#x4E0A;&#x589E;&#x52A0;&#x539F;&#x751F;" class="anchor-navigation-ex-anchor" href="#&#x5728;react-native&#x57FA;&#x7840;&#x4E0A;&#x589E;&#x52A0;&#x539F;&#x751F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5728;React Native&#x57FA;&#x7840;&#x4E0A;&#x589E;&#x52A0;&#x539F;&#x751F;</h3>
<p>&#x5F00;&#x59CB;&#x901A;&#x8FC7;<a href="http://facebook.github.io/react-native/docs/getting-started.html#content" target="_blank">&#x5B98;&#x65B9;&#x6587;&#x6863;&#x5B89;&#x88C5;&#x548C;&#x521D;&#x59CB;&#x5316;</a>React Native&#x9879;&#x76EE;&#x3002;</p>
<h4 id="&#x521B;&#x5EFA;&#x548C;&#x8FD0;&#x884C;react-native-&#x9879;&#x76EE;"><a name="&#x521B;&#x5EFA;&#x548C;&#x8FD0;&#x884C;react-native-&#x9879;&#x76EE;" class="anchor-navigation-ex-anchor" href="#&#x521B;&#x5EFA;&#x548C;&#x8FD0;&#x884C;react-native-&#x9879;&#x76EE;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x521B;&#x5EFA;&#x548C;&#x8FD0;&#x884C;React Native &#x9879;&#x76EE;</h4>
<pre><code>react-native init UtanTop

cd UtanTop

react-native run-android
</code></pre><blockquote>
<p>&#x5982;&#x679C;&#x6CA1;&#x6709;&#x9519;,&#x518D;&#x7EE7;&#x7EED;&#x3002;&#x5982;&#x679C;&#x6709;&#x9519;&#xFF0C;&#x8BF4;&#x660E;&#x4F60;&#x73AF;&#x5883;&#x90FD;&#x6CA1;&#x6709;&#x5B89;&#x88C5;&#x597D;&#xFF0C;&#x54C8;&#x54C8;&#x3002;&#x8BF7;&#x53C2;&#x8003;<a href="http://reactnative.cn/docs/0.41/getting-started.html" target="_blank">&#x73AF;&#x5883;&#x5B89;&#x88C5;&#x6587;&#x6863;</a></p>
</blockquote>
<p>&#x606D;&#x559C;&#x4F60;&#xFF0C;&#x7B2C;&#x4E00;&#x6B65;&#x641E;&#x5B9A;&#x4E86;&#x3002;&#x63A5;&#x4E0B;&#x6765;&#xFF0C;&#x628A;&#x5DE8;&#x5751;&#x7684;&#x5730;&#x65B9;&#x8981;&#x6765;&#x4E86;&#x3002;</p>
<h4 id="&#x628A;&#x539F;&#x751F;&#x7684;-buildgradle-&#x6587;&#x4EF6;&#x5148;&#x96C6;&#x6210;&#x8FDB;&#x53BB;"><a name="&#x628A;&#x539F;&#x751F;&#x7684;-buildgradle-&#x6587;&#x4EF6;&#x5148;&#x96C6;&#x6210;&#x8FDB;&#x53BB;" class="anchor-navigation-ex-anchor" href="#&#x628A;&#x539F;&#x751F;&#x7684;-buildgradle-&#x6587;&#x4EF6;&#x5148;&#x96C6;&#x6210;&#x8FDB;&#x53BB;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x628A;&#x539F;&#x751F;&#x7684; <code>build.gradle</code> &#x6587;&#x4EF6;&#x5148;&#x96C6;&#x6210;&#x8FDB;&#x53BB;</h4>
<p>&#x8FD9;&#x4E00;&#x6B65;&#x6BD4;&#x8F83;&#x7B80;&#x5355;&#xFF0C;&#x5C31;&#x662F;&#x628A;<code>gradle</code>&#x76F8;&#x5173;&#x6587;&#x4EF6;&#x590D;&#x5236;&#x66FF;&#x6362;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#xFF0C;&#x4F60;&#x60F3;&#x7684;&#x597D;&#x7B80;&#x5355;&#x54C8;&#x3002;&#x3002;&#x3002;</p>
<p><strong>&#x6211;&#x5EFA;&#x8BAE;&#xFF1A;</strong></p>
<p>&#x9996;&#x5148;&#x628A;&#x539F;&#x9879;&#x76EE;&#x7684;gradle&#x76F8;&#x5173;&#x6587;&#x4EF6;&#x590D;&#x5236;&#x5230;&#x65B0;&#x5EFA;&#x7684;React Native&#x9879;&#x76EE;&#xFF0C;<em>&#x4E0D;&#x8981;&#x7834;&#x574F;&#x539F;&#x6765;&#x7684;React Native&#x9879;&#x76EE;&#x7684;&#x914D;&#x7F6E;</em>&#x3002;</p>
<blockquote>
<p>&#x5982;&#x679C;&#x539F;&#x751F;&#x9879;&#x76EE;&#x91CC;&#x6709;Module&#xFF0C;&#x5148;&#x4E0D;&#x8981;&#x628A;Module&#x5BFC;&#x5165;&#xFF0C;&#x4E3A;&#x4E86;&#x4FDD;&#x9669;&#xFF0C;&#x628A;&#x6700;&#x7B80;&#x5355;&#x7684;&#x5BFC;&#x5165;&#x3002;</p>
</blockquote>
<h5 id="&#x4FEE;&#x6539;root-&#x76EE;&#x5F55;&#x4E0B;&#x7684;buildgradle"><a name="&#x4FEE;&#x6539;root-&#x76EE;&#x5F55;&#x4E0B;&#x7684;buildgradle" class="anchor-navigation-ex-anchor" href="#&#x4FEE;&#x6539;root-&#x76EE;&#x5F55;&#x4E0B;&#x7684;buildgradle"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4FEE;&#x6539;Root &#x76EE;&#x5F55;&#x4E0B;&#x7684;<code>build.gradle</code></h5>
<pre><code>
allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            url &quot;http://192.168.1.205:8081/repository/utancenter/&quot;
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url &quot;$rootDir/../node_modules/react-native/android&quot;
        }

    }
}
</code></pre><p>&#x5982;&#x679C;&#x6709;&#x5176;&#x4ED6;maven&#x4ED3;&#x5E93;&#x76F4;&#x63A5;&#x8FD9;&#x4E48;&#x5199;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;</p>
<h5 id="&#x914D;&#x7F6E;app&#x76EE;&#x5F55;&#x4E0B;&#x7684;buildgradle"><a name="&#x914D;&#x7F6E;app&#x76EE;&#x5F55;&#x4E0B;&#x7684;buildgradle" class="anchor-navigation-ex-anchor" href="#&#x914D;&#x7F6E;app&#x76EE;&#x5F55;&#x4E0B;&#x7684;buildgradle"><i class="fa fa-link" aria-hidden="true"></i></a>&#x914D;&#x7F6E;app&#x76EE;&#x5F55;&#x4E0B;&#x7684;<code>build.gradle</code></h5>
<pre><code>buildTypes {


//        release {
//            // &#x4E0D;&#x663E;&#x793A;Log
//            buildConfigField &quot;boolean&quot;, &quot;LOG_DEBUG&quot;, &quot;false&quot;
//
//            minifyEnabled enableProguardInReleaseBuilds
//            zipAlignEnabled true
//            shrinkResources true
//            proguardFiles getDefaultProguardFile(&apos;proguard-android.txt&apos;), &apos;proguard-project.txt&apos;
//            signingConfig signingConfigs.release
//
//            applicationVariants.all { variant -&gt;
//                variant.outputs.each { output -&gt;
//                    def outputFile = output.outputFile
//                    if (outputFile != null &amp;&amp; outputFile.name.endsWith(&apos;.apk&apos;)) {
//
//                        //if (&quot;woman&quot;.equals(WOMAN)){
//                        //  def fileName = &quot;WomanTop_v${defaultConfig.versionName}_${variant.productFlavors[0].name}.apk&quot;
//                        //output.outputFile = new File(outputFile.parent+File.separator+&quot;v&quot;+defaultConfig.versionName, fileName)
//                        //} else {
//                        def fileName = &quot;UtanTop_v${defaultConfig.versionName}_${variant.productFlavors[0].name}.apk&quot;
//                        output.outputFile = new File(outputFile.parent + File.separator + &quot;v&quot; + defaultConfig.versionName, fileName)
//                        //}
//
//
//                    }
//                }
//            }
//        }

        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile(&quot;proguard-android.txt&quot;), &quot;proguard-rules.pro&quot;
        }
    }
</code></pre><p>&#x8D34;&#x8FD9;&#x4E2A;&#x7684;&#x610F;&#x601D;&#x5C31;&#x662F;&#x5148;&#x628A;&#x6253;&#x6E20;&#x9053;&#x5305;&#x7684;&#x53BB;&#x6389;&#xFF0C;&#x4F7F;&#x7528;React Native&#x751F;&#x6210;&#x7684;&#x914D;&#x7F6E;&#xFF0C;&#x4E4B;&#x540E;&#x6253;&#x6E20;&#x9053;&#x5305;&#x5728;&#x8BF4;&#xFF0C;&#x8BB0;&#x5F97;&#x628A;&#x4E0B;&#x9762;&#x51E0;&#x6BB5;&#x4E5F;&#x8981;&#x5148;&#x6CE8;&#x91CA;&#x6389;&#x3002;</p>
<pre><code>
//    // &#x591A;&#x6E20;&#x9053;&#x6253;&#x5305;
//    productFlavors {

//        T1 {}
//        T2 {}
//        T3 {}
//
//    }
//
//    productFlavors.all { flavor -&gt;
//        flavor.manifestPlaceholders = [CHANNEL_VALUE: name]
//    }
</code></pre><p>&#x5982;&#x679C;&#x96C6;&#x6210;&#x53CB;&#x76DF;&#x7684;&#x591A;&#x6E20;&#x9053;&#x5305;&#xFF0C;&#x8FD8;&#x9700;&#x8981;&#x5728;<code>AndroidManifest.xml</code>&#x4E2D;&#x6CE8;&#x91CA;&#x6389;&#x3002;</p>
<pre><code> &lt;meta-data
            android:name=&quot;UMENG_APPKEY&quot;
            android:value=&quot;${UMENG_APPKEY}&quot; /&gt;
</code></pre><p>&#x5728;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x8FD8;&#x6CA1;&#x96C6;&#x6210;&#x6E90;&#x7801;&#xFF0C;&#x518D;&#x6267;&#x884C;&#xFF1A;</p>
<pre><code>react-native run-android
</code></pre><blockquote>
<p>&#x5982;&#x679C;&#x7F16;&#x8BD1;&#x901A;&#x8FC7;&#xFF0C;&#x606D;&#x559C;&#x4F60;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x8FC7;&#x90A3;&#x662F;&#x6B63;&#x5E38;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD8;&#x6709;&#x4E00;&#x4E2A;&#x5751;&#x3002;</p>
</blockquote>
<p>&#x6211;&#x7684;&#x62A5;&#x9519;&#x4FE1;&#x606F;&#x662F;</p>
<pre><code>
* What went wrong:
Execution failed for task &apos;:app:packageAllDebugClassesForMultiDex&apos;.
&gt; java.util.zip.ZipException: duplicate entry: bolts/AggregateException.class
</code></pre><p>&#x662F;&#x56E0;&#x4E3A;&#x5BFC;&#x5165;&#x4E86;&#x91CD;&#x590D;&#x7684;&#x6761;&#x76EE;&#x3002;</p>
<blockquote>
<p>&#x53EF;&#x80FD;&#x662F;&#x5728;&#x67D0;&#x4E9B;&#x67D0;&#x4E9B;gradle&#x7248;&#x672C;&#x624D;&#x6709;&#x5427;&#x3002;&#x3002;&#x3002;</p>
</blockquote>
<p>&#x6211;&#x7684;&#x89E3;&#x51B3;&#x65B9;&#x6CD5;&#xFF1A;</p>
<pre><code>    compile(&apos;com.facebook.fresco:fresco:0.10.0&apos;) {
        exclude group: &apos;com.parse.bolts&apos;,
                module: &apos;bolts-android&apos;
    }

    compile (&apos;com.facebook.fresco:animated-gif:0.10.0&apos;){
        exclude group: &apos;com.parse.bolts&apos;,
                module: &apos;bolts-android&apos;
    }
</code></pre><p>&#x8FD9;&#x65F6;&#x5019;&#x518D;&#x6267;&#x884C;&#xFF1A;</p>
<pre><code>react-native run-android
</code></pre><p>&#x73B0;&#x5728;&#x95EE;&#x9898;&#x5E94;&#x8BE5;&#x4E0D;&#x5927;&#x4E86;&#xFF0C;&#x6309;&#x9053;&#x7406;&#x53EF;&#x4EE5;&#x8FD0;&#x884C;&#x8D77;&#x6765;&#x4E86;&#xFF0C;&#x53CD;&#x6B63;&#x6211;&#x7684;&#x8FD0;&#x884C;&#x8D77;&#x6765;&#x4E86;&#xFF0C;&#x4F46;&#x662F;&#x8FD8;&#x6CA1;&#x6709;&#x52A0;&#x5165;&#x6E90;&#x7801;&#x3002;&#x3002;&#x3002;</p>
<h5 id="&#x73B0;&#x5728;&#x5C31;&#x628A;java-res-libs-assets-&#x76EE;&#x5F55;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x548C;-androidmanifestxml-&#x590D;&#x5236;&#x5230;react-native&#x9879;&#x76EE;&#x4E2D;&#x3002;"><a name="&#x73B0;&#x5728;&#x5C31;&#x628A;java-res-libs-assets-&#x76EE;&#x5F55;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x548C;-androidmanifestxml-&#x590D;&#x5236;&#x5230;react-native&#x9879;&#x76EE;&#x4E2D;&#x3002;" class="anchor-navigation-ex-anchor" href="#&#x73B0;&#x5728;&#x5C31;&#x628A;java-res-libs-assets-&#x76EE;&#x5F55;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x548C;-androidmanifestxml-&#x590D;&#x5236;&#x5230;react-native&#x9879;&#x76EE;&#x4E2D;&#x3002;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x73B0;&#x5728;&#x5C31;&#x628A;<code>java</code> <code>res</code> <code>libs</code> <code>assets</code> &#x76EE;&#x5F55;&#x4E0B;&#x7684;&#x6587;&#x4EF6;&#x548C; <code>AndroidManifest.xml</code> &#x590D;&#x5236;&#x5230;React Native&#x9879;&#x76EE;&#x4E2D;&#x3002;</h5>
<p>&#x628A;<code>MainApplication</code> &#x96C6;&#x6210;&#x4F60;&#x539F;&#x751F;&#x9879;&#x76EE;&#x7684;<code>Application</code> </p>
<blockquote>
<p>&#x4E00;&#x822C;&#x9879;&#x76EE;&#x90FD;&#x4F1A;&#x81EA;&#x5B9A;&#x4E00;&#x4E2A;<code>Application</code></p>
</blockquote>
<pre><code>public class MainApplication extends UtanToutiaoApp implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List&lt;ReactPackage&gt; getPackages() {
      return Arrays.&lt;ReactPackage&gt;asList(
          new MainReactPackage()
      );
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}
</code></pre><blockquote>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x4E0D;&#x8981;&#x628A;<code>MainActivity</code> <code>MainApplication</code> ,&#x6587;&#x4EF6;&#x8986;&#x76D6;&#x4E86;&#x3002;</p>
</blockquote>
<p>&#x518D;&#x6267;&#x884C;&#xFF1A;</p>
<pre><code>react-native run-android
</code></pre><p>&#x5E94;&#x8BE5;&#x53EF;&#x4EE5;&#x6210;&#x529F;&#x4E86;&#xFF0C;&#x5982;&#x679C;&#x9ED8;&#x8BA4;&#x542F;&#x52A8;&#x7684;&#x662F;<code>MainActivity</code>&#xFF0C;&#x90A3;&#x5C55;&#x793A;&#x7684;&#x5C31;&#x662F;React Native &#x754C;&#x9762;&#xFF0C;&#x5982;&#x679C;&#x9ED8;&#x8BA4;&#x4E0D;&#x662F;<code>MainActivity</code>&#xFF0C;&#x90A3;&#x5C31;&#x901A;&#x8FC7;&#x4E0B;&#x9762;&#x7684;&#x65B9;&#x5F0F;&#x542F;&#x52A8;&#x3002;</p>
<pre><code>
Intent i = new Intent(context, MainReactActivity.class);

context.startActivity(i);
</code></pre><p>&#x5230;&#x8FD9;&#x91CC;&#x6211;&#x53CD;&#x6B63;&#x5C31;ok&#x4E86;&#xFF0C;&#x4E0D;&#x77E5;&#x9053;&#x4F60;ok&#x4E86;&#x6CA1;&#xFF1F;</p>
<p>&#x5982;&#x679C;&#x4E0D;OK &#xFF0C;&#x8BF7;&#x7559;&#x8A00;&#xFF0C;&#x4E00;&#x8D77;&#x63A2;&#x8BA8;&#x3002;&#x3002;</p>
<p>&#x8FD8;&#x6709;&#x6211;&#x5728;&#x5B66;&#x4E60;&#x548C;&#x4F7F;&#x7528;React Native &#x4E4B;&#x540E;&#x4E5F;&#x4F1A;&#x8D34;&#x51FA;&#x6765;&#x4F9B;&#x5927;&#x4F19;&#x53C2;&#x8003;&#x3002;&#x3002;&#x8BF7;&#x5173;&#x6CE8; quanke </p>
<footer class="page-footer"><span class="copyright">Copyright &amp; copy zengqing.top 2023 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x66F4;&#x65B0;&#x4E8E;&#xFF1A;
2023-03-25 21:17:29
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="CodePush 热更新配置及使用.html" class="navigation navigation-prev " aria-label="Previous page: CodePush 热更新配置及使用">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../Egret/Egret 白鹭引擎参考资料.html" class="navigation navigation-next " aria-label="Next page: Egret 白鹭引擎参考资料">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"已有Android工程 集成React Native","level":"3.2","depth":1,"next":{"title":"Egret 白鹭引擎参考资料","level":"4.1","depth":1,"path":"Egret/Egret 白鹭引擎参考资料.md","ref":"./Egret/Egret 白鹭引擎参考资料.md","articles":[]},"previous":{"title":"CodePush 热更新配置及使用","level":"3.1","depth":1,"path":"ReactNative/CodePush 热更新配置及使用.md","ref":"./ReactNative/CodePush 热更新配置及使用.md","articles":[]},"dir":"ltr"},"config":{"plugins":["expandable-chapters","code","pageview-count","chapter-fold","expandable-chapters-small","tbfed-pagefooter","hide-element","ancre-navigation"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright & copy zengqing.top 2023","modify_label":"该文件更新于：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":true},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"pageview-count":{},"ancre-navigation":{"showLevel":true,"associatedWithSummary":true,"mode":"float","printLog":false,"multipleH1":true,"float":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"XiaoChen","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《前端学习笔记》","language":"zh-hans","gitbook":"*","description":"个人学习笔记，记录学习过程中的点点滴滴"},"file":{"path":"ReactNative/已有Android工程 集成React Native.md","mtime":"2023-03-25T13:17:29.482Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-03-26T04:06:26.355Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

